#include <stdio.h>
#include "time.h"
#include "stdlib.h"
void main()
{
    int stime,a,z,t,i,c,m,g,s,j,k,l[4];
    long ltime;
    ltime=time(NULL);
    stime=(unsigned int)ltime/2;
    srand(stime);
    z=rand()%9999;
    printf("I have a number with 4 difirs in mind,please guess.\n");
    for(c=1;;c++)
    {
        printf("Enter a number with 4 digits:");
        scanf("%d",&g);
        a=z;j=0;k=0;l[0]=l[1]=l[2]=l[3]=0;
        for (i=1;i<5;i++)
        {
            for(t=1;t<5;t++)
            {

            
                if(a%10==s%10)
                {
                    if(m&&t!=l[0]&&t!=l[1]&&t!=l[2]&&t!=l[3])
                    {
                        j++;m=0;l[j-1]=t;
                    }
                    if(i==t)
                        k++;
                }
                s/=10;
            }
            a/=10;
        }
        printf("You have correctlu guesseed %d digits in exact position.\n",j);
        printf("and correctly guessed %d digits in exact position.\n",k);
        if(k==4)
            break;
        
    }
    printf("Now you have correctly guessed the wholw number after %d timees.\n",c);
    
}